package com.study.java8;

import java.util.function.Consumer;

/**
 * @author ysy
 * @version 1.0
 * @Title: ConsumerTest
 * @Note <b>ProjectName:</b> cusc-venus
 * <br><b>PackageName:</b> com.cusc.venus.acc.center.util
 * <br><b>ClassName:</b>
 * <br><b>Date:</b>
 *
 */
public class ConsumerTest {

    public static void main(String[] args) {
        // 消费型函数式接口：有输入无返回 void accept(T t)
        Consumer consumer = System.out::println;
        consumer.accept("hello function");

        // 默认方法andThen：按顺序执行
        Consumer<String> consumer1 = s -> System.out.print("车名："+s.split(",")[0]);
        Consumer<String> consumer2 = s -> System.out.println("  颜色："+s.split(",")[1]);
        Consumer<String> consumer3 = s -> System.out.println("  颜色："+s.split(",")[2]);
        String[] strings = {"保时捷,白色", "法拉利,红色", "比亚迪,银色"};
        for (String string : strings) {
            consumer1.andThen(consumer2).accept(string);
        }


    }
}
